package com.kotlin.lib

val words = "The quick brown fox jumps over the lazy dog".split(" ")

/**
 * 下面的代码过滤⻓于三个字符的单词，并打印前四个单词的⻓度。
 */
fun filteByList() {
    words.filter {
        println("filter list...$it")
        it.length > 3
    }.take(1).forEach(::println)
}

fun filteBySequence() {
    words.asSequence().filter {
        println("filter sequence...$it")
        it.length > 3
    }.take(1).forEach(::println)
}

fun main() {
    filteByList()
    println("-------------------")
    filteBySequence()
}

